Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • global NT = `: word count `r(varlist)''*

    What does it mean?:


    global NT = `: word count `r(varlist)''
    global NT_1 = $NT - 1

  • #2
    First find the number of variables that comes out of some command, then subtract 1.

    Code:
    help macro
    
    help extended fcn
    We can't guess where r(varlist) comes from with zero context.

    Comment


    • #3
      Thanks Nick!

      I am trying to understand the following estimation with fixed effects:


      quietly ds EXPORTER_TIME_FE*
      global NT = `: word count `r(varlist)''
      global NT_1 = $NT - 1

      quietly tabulate year, gen(TIME_FE)
      quietly ds TIME_FE*
      global Nyr = `: word count `r(varlist)''
      global NT_yr = $NT - $Nyr

      quietly ds PAIR_FE*
      global NTij = `: word count `r(varlist)''
      global NTij_1 = $NTij - 1
      global NTij_8 = $NTij - 8

      ppml trade PAIR_FE1-PAIR_FE$NTij_1 EXPORTER_TIME_FE* IMPORTER_TIME_FE1-IMPORTER_TIME_FE$NT_yr RTA, iter(30) noconst


      However, I do not understand the meaning of "-1" and "-8".
      Not sure if is related with the number of year of the data panel....

      Comment


      • #4
        Evidently, -1 and -8 mean subtract 1 and subtract 8. Why that is a good idea for these data, which you don't explain, I do not know.

        ppml is a community-contributed command, as you are asked to explain (FAQ Advice #12). Joao Santos Silva may be able to help.

        The code seems confused to me, as I would expect ppml to understand varlists in the standard way, allowing the use of wildcards. Indeed there is a wildcard in the syntax you cite.

        Where did you find this? What is the (fuller) context?

        Comment


        • #5
          Dear Daniel Gomez and Nick Cox,

          I am afraid I have no idea why that is being done; ppml should just drop the variables that are collinear, so there is no particular reason to do things this way.

          Best wishes,

          Joao

          Comment


          • #6
            Thank you for your answers Nick Cox and Joao Santos Silva !


            It is from a general equilibrium analysis using a data panel of these years: 1986, 1990 ,1994 ,1998 ,2002, 2006:


            *Create exporter time fixed effects
            egen exp_time = group(exporter year)
            quietly tabulate exp_time, gen(EXPORTER_TIME_FE)

            * Create importer time fixed effects
            egen imp_time = group(importer year)
            quietly tabulate imp_time, gen(IMPORTER_TIME_FE)

            * Rearrange so that country pairs (e.g. NER-PAN, MWI-MAC, NPL-MWI, PAN-MWI, NPL-CMR), which will be dropped due to no trade, are last
            bysort pair_id: egen X = sum(trade)
            quietly summarize pair_id
            replace pair_id = pair_id + r(max) + 1 if X == 0 | X == .
            drop X

            * Rearrange so that the last country pair is the one for internal trade
            quietly sum pair_id
            replace pair_id = r(max) + 1 if exporter == importer
            quietly tabulate pair_id, gen(PAIR_FE)

            * Set additional exogenous parameters
            quietly ds EXPORTER_TIME_FE*
            global NT = `: word count `r(varlist)''
            global NT_1 = $NT - 1

            quietly tabulate year, gen(TIME_FE)
            quietly ds TIME_FE*
            global Nyr = `: word count `r(varlist)''
            global NT_yr = $NT - $Nyr

            quietly ds PAIR_FE*
            global NTij = `: word count `r(varlist)''
            global NTij_1 = $NTij - 1
            global NTij_8 = $NTij - 8

            * Save data
            save "Datasets/2_RTAsEffects.dta", replace


            ************************* GENERAL EQUILIBRIUM ANALYSIS *************************

            * Step I: Solve the baseline gravity model

            * Step I.a. Obtain estimates of trade costs and trade elasticities baseline
            * indexes

            * Implementation of Anderson and Yotov (2016) two-stage procedure to construct the full matrix of trade costs, including when there is no trade or zero trade

            * Stage 1: Obtain the estimates of pair fixed effects and the effects of RTAs:

            ppml trade PAIR_FE1-PAIR_FE$NTij_1 EXPORTER_TIME_FE* IMPORTER_TIME_FE1-IMPORTER_TIME_FE$NT_yr RTA, iter(30) noconst
            estimate store gravity_panel
            scalar RTA_est = _b[RTA]

            Comment


            • #7
              Dear Daniel Gomez,

              I'm not sure if you solved this problem. NTij_1 in the ppml estimators means removing the intranational trade. NTij_8 in the ppml estimators means to remove bilateral trade as 0 or missing values, and remove domestic trade.

              Hope this is helpful!

              Best wishes,

              Zhou

              Comment

              Working...
              X